package org.zhadoop.stream.cql.semanticanalyzer.parser.visitor;

import org.antlr.v4.runtime.misc.NotNull;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.FromSourceContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.JoinRigthBodyContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.JoinSourceContext;

/**
 * Join 语法定义解析
 *  a join b join c 应该先处理b join c，再用Join的结果和a做Join
 * @author zwd
 *
 */
public class JoinSourceVisitor extends AbsCQLParserBaseVisitor<JoinSourceContext>{

	private JoinSourceContext context = null;
	
	public JoinSourceVisitor() {
		context = new JoinSourceContext();
	}
	
	@Override
	protected JoinSourceContext defaultResult() {
		return context;
	}

	@Override
	public JoinSourceContext visitFromSource(@NotNull FromSourceContext ctx) {
		FromSourceVisitor visitor = new FromSourceVisitor();
        context.setLeftStream(visitor.visit(ctx));
        return context;
	}
	
	@Override
	public JoinSourceContext visitJoinRigthBody(@NotNull JoinRigthBodyContext ctx) {
		JoinRightBodyVisitor visitor = new JoinRightBodyVisitor();
        context.getJoinRightBody().add(visitor.visit(ctx));
        return context;
	}
		
}
